

#include "../../matrix/matrix.h"

ImpMatrix * imp_strel_disk(float ray, int w) {
	ImpMatrix * SE = NULL;
	int r, c;
	//int w = ray * 2 + 1;

	float r2 = ray*ray;
	float cc = (w-1)/2.0;

	SE = imp_matrix_new(w, w);

	for (r = 0; r < w; r++) {

		float dr = r - cc;
		dr = dr*dr;

		for (c = 0; c < w; c++) {

			float dc = c - cc;
			dc = dc*dc;

			if ((dr + dc) > r2) SE->data[ c + r * w ] = 0;
			else SE->data[ c + r * w ] = 1;
		}
	}
	
	return SE;
}